#ifndef __JSONTYPES_H__
#define __JSONTYPES_H__
#include <variant>
#include <string>
#include <optional>
namespace wj
{
// RFC7159 - ABNF
enum class JSONType
{
    JSON_NULL,    // Null type， literal "null"
    JSON_FALSE,   // False type, literal "false"
    JSON_TRUE,    // True type, literal "true"
    JSON_NUMBER,  // Number type
    JSON_STRING,  // String type
    JSON_ARRAY,   // Array type
    JSON_OBJECT   // Object type
};

struct JSONValue
{
    std::variant<std::string, double, bool, std::nullopt_t> data;
    JSONType type{JSONType::JSON_NULL};
    double GetNumber()
    {
        return std::get<double>(data);
    }
    template <typename T>
    auto Get()
    {
        return std::get<T>(data);
    }
    JSONType GetType()
    {
        return type;
    }
};

enum class RetCode
{
    OK,                           // Nothing wrong
    PARSE_EXPECT_VALUE,           // Expect to be a value
    PARSE_INVALID_VALUE,          // Value not in "true", "false", "null"
    PARSE_ROOT_NOT_SINGULAR,      // After a value, there is more chars
    PARSE_NUMBER_OVERFLOW,        // Parsing a number that may overflow
    PARSE_MISS_QUOTEMARK,         // Miss pair string quote mark
    PARSE_INVALID_STRING_ESCAPE,  // Invalid escape char
    PARSE_INVALID_STRING_CHAR     // Invalid char
};

}  // namespace wj

#endif  // __JSONTYPES_H__